import { create } from 'zustand'
import { persist } from 'zustand/middleware'
import $helper from '@renderer/services/helper.service'

export type SettingStoreType = {
  saveDir: string
  replaceOrigin: boolean
  systemDownloadDir: string
}

const useSettingStore = create<SettingStoreType>(
  // @ts-ignore
  persist(
    (set) => {
      return {
        saveDir: "",
        replaceOrigin: false,
        systemDownloadDir: "",
      }
    },
    {
      name: $helper.md5('food-storage'), // unique name
      // storage: createJSONStorage(() => sessionStorage), // (optional) by default, 'localStorage' is used
    }
  )
)


export default useSettingStore